<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite + Vue + TS</title>
  </head>
  <body>
    <div id="app"></div>
    <script>
      const getUrlByImage = (message, stack) => {
        var img = new Image();
        img.src = `http://127.0.0.1:5173/api/pushErrorInfo?path=${
          window.location.pathname
        }&message=${message}&stack=${stack}&timestamp=${new Date().getTime()}`;
      };
      window.addEventListener("unhandledrejection", (event) => {
        const {
          error, // 错误对象
          promise, // 出现异常的promise对象
        } = event;
        console.log(event);
        console.log(event.reason);
        getUrlByImage(event.reason.message, event.reason.stack);
        event.preventDefault();
      });
      window.onerror = function (message, source, lineno, colno, error) {
        getUrlByImage(error.message, error.stack);
        // console.log("捕获到异常：", { message, source, lineno, colno, error });
        console.log(error)
      };
      console.log("gettime", window.chrome.loadTimes());
    </script>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>
